package com.lei.service.impl;

import com.lei.dao.UserDao;
import com.lei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author Admin
 * @Date 2021/8/3 15:29
 * @Version 1.0
 */
@Service("userService")
//@Scope("prototype")
//@Scope("singleton")

public class UserServiceImpl implements UserService {
@Value("张三")
    public String name;
@Value("${jdbc.driver}")
    public String Driver;
//    @Autowired
//    @Qualifier("userDao")
    @Resource(name = "userDao")
    public UserDao userDao;
    @PostConstruct
    public void init(){
        System.out.println("初始化方法");
    }
    public void save() {
        System.out.println("name:"+name);
        System.out.println("Driver:"+Driver);
        userDao.save();
    }
    @PreDestroy
    public void destroy(){
        System.out.println("销毁方法");
    }
}
